package com.github.mjchow.web.controller;

import com.github.mjchow.domain.Student;
import com.github.mjchow.model.StudentMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class HelloController {

    @Resource
    private StudentMapper studentMapper;

    @RequestMapping("/hello")
    public String index() {
        return "Hello World";
    }

    @RequestMapping("/insert")
    public String insert() {
        Student student = new Student();
        student.setName("CCC");
        student.setAge(19);
        student.setSex(1);
        studentMapper.insert(student);
        return "ok";
    }

    @RequestMapping("/errorx")
    public String error() {
        int a = 1/0;
        System.out.println(a);
        return "ok";
    }
}